package cn.stylefeng.guns.base.utils;

import lombok.Data;

import java.util.Arrays;
import java.util.List;

/**
 * @program: football_manage
 * @description:
 * @author: xiesm
 * @create: 2023-09-15 10:07
 **/
@Data
public class Ao81Model {
    private String issue;
    private Integer code1;
    private Integer code2;
    private Integer code3;
    private Integer code4;
    private Integer code5;
    private Integer code6;
    private Integer code7;
    private Integer code8;


    public Ao81Model(String issue, String[] preDrawCodes) {
        this.issue = issue;
        this.code1 = Integer.valueOf(preDrawCodes[0]);
        this.code2 = Integer.valueOf(preDrawCodes[1]);
        this.code3 = Integer.valueOf(preDrawCodes[2]);
        this.code4 = Integer.valueOf(preDrawCodes[3]);
        this.code5 = Integer.valueOf(preDrawCodes[4]);
        this.code6 = Integer.valueOf(preDrawCodes[5]);
        this.code7 = Integer.valueOf(preDrawCodes[6]);
        this.code8 = Integer.valueOf(preDrawCodes[7]);
//        System.out.println(StrUtil.format("{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t",
//                issue, code1, code2, code3, code4, code5, code6, code7, code8));
    }

    public Ao81Model(String issue, Integer[] preDrawCodes) {
        this.issue = issue;
        this.code1 = preDrawCodes[0];
        this.code2 = preDrawCodes[1];
        this.code3 = preDrawCodes[2];
        this.code4 = preDrawCodes[3];
        this.code5 = preDrawCodes[4];
        this.code6 = preDrawCodes[5];
        this.code7 = preDrawCodes[6];
        this.code8 = preDrawCodes[7];
    }

    public Integer getCode(Integer num) {
        Integer code = null;
        switch (num) {
            case 1:
                code = getCode1();
                break;
            case 2:
                code = getCode2();
                break;
            case 3:
                code = getCode3();
                break;
            case 4:
                code = getCode4();
                break;
            case 5:
                code = getCode5();
                break;
            case 6:
                code = getCode6();
                break;
            case 7:
                code = getCode7();
                break;
            case 8:
                code = getCode8();
                break;
        }
        return code;
    }

    public Integer hasCode(Integer code) {
        return Arrays.asList(code1, code2, code3, code4, code5, code6, code7, code8).lastIndexOf(code);
    }

    public static void main(String[] args) {
        List<Integer> codes = Arrays.asList(1, 3, 5, 7, 9, 11, 15, 19);
        System.out.println(codes.lastIndexOf(7));
        System.out.println(codes.lastIndexOf(19));
        System.out.println(codes.lastIndexOf(20));
    }
}
